@extends('layouts.app')
@section('title', '员工账号')

@section('content')
    <div class="tab">
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-12">
                    <table class="table table-striped">
                        <caption>员工账号信息管理</caption>
                        <thead>
                        <tr>
                            <th>员工编号</th>
                            <th>账号名称</th>
                            <th>邮箱</th>
                            <th>职务</th>
                            <th>权限</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($list as $v)
                            <tr id="{{$v->id}}">
                                <td>{{$v->id}}</td>
                                <td>{{$v->name}}</td>
                                <td>{{$v->email}}</td>
                                <td>{{$v->auth_name}}</td>
                                <td>
                                    @if($v->id == 1)
                                        拥有所有权限
                                    @else
                                        @foreach($v->getAllPermissions() as $permission)
                                            【{{ $permission->desc_name }}】
                                        @endforeach
                                    @endif
                                </td>
                                <td>
                                    @if($v->id != 1)
                                        <a class="update btn btn-info" href="{{ route('users.permission', $v) }}" >权限分配</a>


                                        <form action="{{ route('users.destroy', [$v->id]) }}" method="post" style="float: left" >
                                            {{ csrf_field() }}
                                            {{ method_field('DELETE') }}
                                            <button type="submit" class="btn btn-danger">删除</button>
                                        </form>
                                        @endif
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                    {{--<a class="pull-right btn btn-primary" href="{{ route('users.create') }}">添加员工</a>--}}
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="text-center">
                        {{$list->render()}}
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection